<!DOCTYPE html>
<html>
<head>
<script>
const inputs = 1;
function sleep(miliseconds) {
   var currentTime = new Date().getTime();
   while (currentTime + miliseconds >= new Date().getTime()) {
   }
}

async function playSourceNode(audioContext) {
  let soundSource1 = audioContext.createConstantSource();
  await audioContext.audioWorklet.addModule('tear-down.js');
  let worklet;
  worklet = new AudioWorkletNode(audioContext, 'tear-down');
  let delay = audioContext.createDelay(0.01);
  soundSource1.connect(worklet).connect(delay).connect(audioContext.destination);
  soundSource1.start();
  return [soundSource1, worklet];
}

function onLoad() {
	let audioCtx = new OfflineAudioContext(1,44100, 44100);
    playSourceNode(audioCtx).then((src)=>{
      audioCtx.startRendering();
      sleep(200);
      src[0].disconnect();
      src[1].disconnect();
      parent.removeVirtual();
    });
}

</script>
</head>
<body onload="onLoad()"/>
</html>
